//
//  JMAuthentiactionConfirmView.m
//  NewiOSProject
//
//  Created by li on 2023/9/5.
//  Copyright © 2023 范智渊. All rights reserved.
//

#import "JMAuthentiactionConfirmView.h"
#import "CustomStackView.h"
#import "PaddingView.h"

@interface JMAuthentiactionConfirmView ()

@property(nonatomic, strong, nonnull) CustomStackView *stackView;



@end
@implementation JMAuthentiactionConfirmView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        
        [self setupViews];
    }
    return self;
}

- (void)setupViews {
    
    self.stackView = [CustomStackView init:(UILayoutConstraintAxisVertical)];
    self.stackView.spacing = 18;
    
    self.rootView = [PaddingView initWithContentView:self.stackView edgeInsets:(UIEdgeInsetsMake(10, 20, 18, 20))];
    self.rootView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    [self addSubview:self.rootView];

    [self.confirmBut.heightAnchor constraintEqualToConstant:56].active = YES;
    [self.stackView addArrangedSubview:self.confirmBut];
    
    UIButton *reading = [UIButton buttonWithType:(UIButtonTypeCustom)];
    reading.titleLabel.font = [UIFont systemFontOfSize:12];
    [reading setTitle:@"《 Politica de privacidad 》" forState:(UIControlStateNormal)];
    [reading setTitleColor: [UIColor colorWithHexString:@"#222222"] forState:(UIControlStateNormal)];
    [reading.heightAnchor constraintEqualToConstant:36].active = YES;
    [reading addTarget:self action:@selector(viewPrivacyAgreement:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.stackView addArrangedSubview:reading];
    
    self.reading = reading;
}

-(JMLoadingButton *)confirmBut{
    if (!_confirmBut) {
        _confirmBut = [[JMLoadingButton alloc]initWithFrame:(CGRectMake(24,0,kAppW()-48, 56)) title:@"Entregar" font:Font(17) titleLabelColor:HexAlpha_Str_COLOR(@"#ffffff", 1) backgoundColor:nil action:nil target:self];
        _confirmBut.cornerRadius = 28;
        _confirmBut.enable = NO;
    }return _confirmBut;
}
- (void)viewPrivacyAgreement: (UIButton *)sender {
    [JMCommonMethod presentWebviewWithUrl:serviceUrlWith(loginPrivacyAgreement) andTitle:@"Politica de privacidad"];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
